﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mimoza.Transport
{
    /// <summary>
    /// This class represent used data for transport layer.
    /// TransferObject should be register in Transport.Dispatcher
    /// see additional helpers genereic-class UserObjectGeneric
    /// </summary>
    abstract public class TransferObject
    {
        /// <summary>
        /// Serialize itself in stream.
        /// </summary>
        abstract public void Serialize(Stream stream);

        /// <summary>
        /// Deserialize new created object from stream
        /// </summary>
        abstract public TransferObject Deserialize(Stream stream);

        /// <summary>
        /// Name of type of TransferObject
        /// </summary>
        abstract public string TypeName { get; }

        /// <summary>
        /// Remote address of host that sent this object
        /// </summary>
        abstract public string RemoteAddress { get; set;  }

        /// <summary>
        /// Process arrived request.
        /// </summary>
        abstract public void ProcessRequest(Connection conn, out TransferObject replyData);

        /// <summary>
        /// Request connection.
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        abstract public Connection Connection { get; set; }
    }
}
